/******************************************************************************
 cnome: A C++ source "genes" discover. :-)

 See more details at:

   http://www.codeplex.com/cnome

 The original author site is at: http://www.alemosbarbosa.com/

 Copyright (c) 2008-2010 Alexandre Lemos Barbosa.
 Distributed under the MIT License. (See accompanying file LICENSE-MIT.txt 
 or at http://www.codeplex.com/cnome/license)
 ******************************************************************************/

#ifndef SCOPES_H
#define SCOPES_H

#include <string>

#include "typedefs.h"
    
namespace cnome { namespace scopes {
class scopesFromStr {
public:
    scopesFromStr(const std::string& v, size_t suffixSize = std::string::npos);
    const std::string& current_scope()const;
    const std::string& next_scope();

private:
    bool m_first_time;
    size_t m_idx;
    const std::string& m_value;
    std::string m_scope;
    std::size_t m_suffixSize;
    lstItSblsT::const_iterator m_idxLstItSbls;

    void advance_idx();
    std::size_t find_right_char(size_t leftIdx, char leftChar, char rightChar);
    std::size_t find_right_parenthesis(std::size_t leftIdx);
    std::size_t find_greater(std::size_t leftIdx);
};

class scopesFromScp {
public:
    scopesFromScp(const symbolPtr& v, size_t suffixSize = std::string::npos );
    const std::string& currentScope()const;
    const std::string& nextScope();

private:
    std::size_t m_suffixSize;
    const symbolPtr m_sbl;
    std::string m_value;
};

void enter_scope(std::string& val, iterator& first);
std::string& get_scope(std::string& scp, const char* tk=0);
std::string& get_previous_scope(std::string& scp);
const itSymbolItem get_symbol_scope(const char* scp);
std::string& get_scope(std::string& scp, scopeT& tk, bool useCurScope = true);
std::string& get_scope(std::string& scp, scopeT& tk, size_t& suffixSize, bool useCurScope = true);
}} // namespace cnome { namespace scopes {

#endif // SCOPES_H
